package it.polito.let.http;

public class Request extends Message {

	private String requestURL = null;

	private HTTPMethod requestType;

	public String getRequestURL() {
		return requestURL;
	}

	public String getRequestPath() {
		int index = requestURL.indexOf('?');
		if (index==-1)
			return requestURL;
		return requestURL.substring(0,index);
	}

	public String getRequestFile() {
		String query = getRequestPath();
		int start = query.lastIndexOf("/") == -1 ? 0 : query.lastIndexOf("/")+1;  // ignore sub-directories
		return query.substring(start);
	}


	public void setRequestURL(String requestURL) {
		this.requestURL = requestURL;
	}

	public HTTPMethod getRequestType() {
		return requestType;
	}

	public void setRequestMethod(HTTPMethod requestType) {
		this.requestType = requestType;
	}
}
